package com.pan.entity.transmit;

import com.pan.enumn.MessageEnum;

import java.io.Serializable;

public class Packet<T> implements Serializable {

    int code;
    String message;
    T data;

    @Override
    public String toString() {
        return "Packet{" +
                "code=" + code +
                ", message='" + message + '\'' +
                ", data=" + data +
                '}';
    }

    public Packet(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public Packet(MessageEnum e ,T data) {
        this(e.getCode(),e.getMsg(),data);
    }

    public Packet(MessageEnum e) {
        this(e.getCode(),e.getMsg(),null);
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
